package com.example.book.repository;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.example.book.model.Book;

public class BookList {

	Map<String, Book> bookMap = new HashMap<>();
	
	
	public Map<String, Book> getBookMap() {
		return bookMap;
	}

	public BookList() {
		
		Book roman = new Book("01AB-01", "Longue lettre", "Mariama Ba", 18);
		Book fantasy = new Book("02-33AD", "Game of Thrones", "Ibrahima Yock",
				20);
		Book java = new Book("033-AD", "JSP", "J.K. Row", 19);
		bookMap.put("01AB-01", roman);
		bookMap.put("02-33AD", fantasy);
		bookMap.put("033-AD", java);
	}

	public List<Book> getBooks() {

		List<Book> allBooks = new ArrayList<>(bookMap.values());
	
		return allBooks;

	}

	public Book getBook(String isbn){
		return bookMap.get(isbn);
	}
}
